﻿<Views:WindowBase x:Class="SharpTalk.Client.WpfApplication.Views.ChatRoomSearchView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        mc:Ignorable="d" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:Resources="clr-namespace:SharpTalk.Client.WpfApplication.Resources"
        xmlns:Views="clr-namespace:SharpTalk.Client.WpfApplication.Views" d:DesignHeight="300" d:DesignWidth="320"
        xmlns:Controls="clr-namespace:SharpTalk.Client.WpfApplication.Controls"
        MinWidth="320" MinHeight="300"
        Style="{StaticResource MessageViewStyle}"
        Title="{x:Static Resources:Messages.label_search_chatroom}"
        SizeToContent="WidthAndHeight">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <Controls:TextBoxButton
                x:Name="searchBox"
                Grid.Row="0"
                Grid.ColumnSpan="2"
                Margin="5"
                InsideBorderCornerRadius="3"
                InsideBorderThickness="1" 
                InsideBorderBrush="{StaticResource LightGrayBrushKey}"
                ButtonCommand="{Binding SearchCommand}">
                <Controls:TextBoxButton.ButtonContent>
                    <Image Style="{StaticResource ImageSearch}" ToolTip="{x:Static Resources:Messages.label_search}" />
                </Controls:TextBoxButton.ButtonContent>
                <Controls:TextBoxButton.TextBoxToolTip>
                    <ToolTip Content="{x:Static Resources:Messages.label_name}"/>
                </Controls:TextBoxButton.TextBoxToolTip>
            </Controls:TextBoxButton>
        </Grid>
        
        <!-- Search result view -->
        <ListView Grid.Row="1" ItemsSource="{Binding SearchResult}" SelectedItem="{Binding SelectedChatRoom}" SelectionMode="Single" IsSynchronizedWithCurrentItem="True" BorderThickness="0" HorizontalContentAlignment="Stretch">
            <ListView.View>
                <GridView>
                    <GridViewColumn 
                        Header="{x:Static Resources:Messages.label_name}"
                        DisplayMemberBinding="{Binding Name}" />
                </GridView>
            </ListView.View>
        </ListView>
        
        <!--Busy indicator -->
        <StackPanel Name="busyPanel"  Margin="5,0,5,0" Grid.Row="1" HorizontalAlignment="Center" Orientation="Vertical" VerticalAlignment="Center" Visibility="{Binding IsSearching, Converter={StaticResource BooleanToVisibilityConverter}}" Panel.ZIndex="100">
            <TextBlock Text="{x:Static Resources:Messages.label_searching}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            <ProgressBar Width="200" IsIndeterminate="True" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
        </StackPanel>

        <Controls:DialogActionsPanel 
            Grid.Row="2"
            Grid.ColumnSpan="2"
            VerticalAlignment="Bottom"
            HorizontalAlignment="Right"
            ShowButtonOk="True"
            ShowButtonCancel="True"
            ButtonOkContent="{x:Static Resources:Messages.label_join}"
            ButtonOkCommand="{Binding ValidateCommand}"
            ButtonOkIsEnabled="{Binding CanJoin}"/>
        
    </Grid>
</Views:WindowBase>
